<?php
namespace app\api\model\wanlshop;

use think\Model;
use think\Request;

class Category extends Model
{

    // 表名
    protected $name = 'wanlshop_category';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    public function getNameAttr($value,$data){
        $request = Request::instance();
        $lang = $request->langset();
        if($lang == 'en'){
            $value = isset($data['name_en']) ? ($data['name_en'] ? $data['name_en'] : $value) : $value;
        }
        return $value;
    }
}
